<?php

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
	<title>{$TitrePage}</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<form>
	<input type="text" name="test"/>
</form>
<pre>
<?php
function check_utf8($str) { 
    $len = strlen($str); 
    for($i = 0; $i < $len; $i++){ 
        $c = ord($str[$i]); 
        if ($c > 128) { 
            if (($c > 247)) return false; 
            elseif ($c > 239) $bytes = 4; 
            elseif ($c > 223) $bytes = 3; 
            elseif ($c > 191) $bytes = 2; 
            else return false; 
            if (($i + $bytes) > $len) return false; 
            while ($bytes > 1) { 
                $i++; 
                $b = ord($str[$i]); 
                if ($b < 128 || $b > 191) return false; 
                $bytes--; 
            } 
        } 
    } 
    return true; 
} // end of check_utf8


var_dump(check_utf8("é"));
var_dump(check_utf8("eée"));
var_dump(check_utf8($_GET['test']));
var_dump(check_utf8(''));

$DBNAME = "japword";
$HOST = "localhost";
$USERNAME = "root";
$PASSWORD = "";

$db = new PDO("mysql:host=$HOST;dbname=$DBNAME", $USERNAME, $PASSWORD, array( PDO::ATTR_PERSISTENT => false));
$st = $db->prepare('SELECT terms.*, translations.* FROM terms JOIN translations ON translations.id_term = terms.id_term', array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$st->execute();

while ($row = $st->fetch()) {
	echo "Row 1 fetched: \n";
	print_r($row);
	
	$row2 = $st->fetch(PDO::FETCH_BOTH, PDO::FETCH_ORI_REL, 3);
	
	echo "Row 1 fetched 2: \n";
	print_r($row2);
}

?>
</pre>
</body>
</html>